Imports System.Collections.Generic
Imports System.IO

Namespace provider
	Public Class FileSysPathDataProvider
		Implements IAutoCompleteDataProvider
		Public Function GetItems(textPattern As String) As IEnumerable(Of String) Implements IAutoCompleteDataProvider.GetItems
			If textPattern.Length < 2 OrElse textPattern(1) <> ":"C Then
				Return Nothing
			End If
			Dim lastSlashPos = textPattern.LastIndexOf("\"C)
			Dim baseFolder = textPattern
			Dim partialMatch As String = Nothing
			If lastSlashPos <> -1 Then
				baseFolder = textPattern.Substring(0, lastSlashPos)
				partialMatch = textPattern.Substring(lastSlashPos + 1)
			End If
			Try
				Return Directory.GetDirectories(baseFolder & "\"C, partialMatch & "*")
			Catch
				Return Nothing
			End Try
		End Function
	End Class
End Namespace
